package nowcoder.written_examination.wangyi;

import java.util.Scanner;

/**
 * @author fance
 * @date 18-7-2 上午10:50
 */
public class MainV {
    public static void main(String[] args) {
//b();
    c();
    }
    public static void c() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            int k = scanner.nextInt();
            int[][] area = new int[n][m];
            for (int i = 0; i < k; i++) {
                area[scanner.nextInt() - 1][scanner.nextInt() - 1]++;
            }
            int res = 0;
            if (n <= 3 && m <= 3) {
                for (int cnt = 0; cnt < 2; cnt++) {
                    for (int i = 0; i < n; i++) {
                        for (int j = 0; j < m; j++) {
                            if (area[i][j] > 0) {
                                res++;
                                area[i][j]--;
                            }
                        }
                    }
                }
                System.out.println(res);
            }

        }
    }
    public static void b() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int r = scanner.nextInt();
            int x1 = scanner.nextInt();
            int y1 = scanner.nextInt();
            int x2 = scanner.nextInt();
            int y2 = scanner.nextInt();
            int x3 = scanner.nextInt();
            int y3 = scanner.nextInt();
            int x0 = scanner.nextInt();
            int y0 = scanner.nextInt();
            int cnt = 0;
            if (canFight(x0,y0,x1,y1,r)) {
                cnt++;
            }
            if (canFight(x0,y0,x2,y2,r)) {
                cnt++;
            }
            if (canFight(x0,y0,x3,y3,r)) {
                cnt++;
            }
            System.out.println(cnt + "x");
        }
    }
    public static boolean canFight(int x0,int y0,int x,int y,int r) {
        if (((x0 - x) * (x0 - x) + (y0 - y) * (y0 - y)) <= r * r) {
            return true;
        }
        return false;
    }
    public static void a() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int a = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                int b = scanner.nextInt();
                if (b <= a) {
                    a += b;
                } else {
                    a += gcd(a,b);
                }
            }
            System.out.println(a);
        }
    }
    public static int gcd(int m,int n) {
        return n == 0 ? m : gcd(n,m % n);
    }
}
